<script type="text/javascript">
	$(document).ready(function(){
		$("input,select,textarea").not("[type=submit]").jqBootstrapValidation();
	});
</script>



	<select class="span12" id="panngan3" name="panngan3" required>
		<option value="">เลือก...</option>
<?php
	require_once("includes/connect.php");
	require_once("includes/function.php");

	$panngan2_id = $_REQUEST["panngan2"];
	$panngan3 = $_REQUEST["panngan3"];

	//echo $panngan3;

	$db = NEW myDBS;
	$db->selectDB("hr_udoncity");
	
	$sql = "SELECT DISTINCT panngan3_id 
				FROM position 
				WHERE lvl_id like '" .$_SESSION["lvl1_id"]. "%'
				AND panngan2_id ='$panngan2_id'"
				; 

	//echo $sql;

	$result = $db->runSQL($sql);
	
	while($rows = $db->fetch_object ( $result )){
		$db->selectDB("account");
		$sql = "SELECT DISTINCT * FROM panngan3 WHERE panngan3_id = '" .$rows->panngan3_id. "'";
		$result1 = $db->runSQL($sql);
		while($rows1 = $db->fetch_object ( $result1 )){
			if ($rows1->panngan3_id == $panngan3) {
				$selected = " selected";
			} else {
				$selected = "";
			}

			echo "<option value='".$rows1->panngan3_id."' $selected>$rows1->panngan3_name</option>";
			//echo "<option value='".$rows1->panngan3_id."'>$rows1->panngan3_name</option>";
		}

	
	}

?>
</select>




